<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page session="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>

<script type="text/javascript" src="http://apis.daum.net/maps/maps3.js?apikey=544d018ccd28d54cfc3e376a6c2a2068976a88fb0" charset="utf-8"></script>

<meta name="viewport" content="width=device-width; initial-scale=1.0" />
		
		
<title>Get gps</title>
</head>
<body>
	
	<div data-role="page"  data-theme="b">
			
			<header data-tap-toggle="false" data-position="fixed" data-role="header" role="banner">
				
				<a href="#menuPanel" data-role="button" data-icon="bars" data-iconpos="notext" data-theme="b" data-inline="true">Bars</a>
				
				<h1 id="centerheader">
					<a href="main.html">
						<img src="resources/img/aa.png" alt="" />
					</a>
				</h1>
				<h5>${sessionScope.userLoginInfo.name}님 환영합니다.</h5>
				<a href="#rightpanel" data-role="button" data-icon="grid" data-iconpos="notext" data-theme="b" data-inline="true">Grid</a>
				
			</header>
							
			
			
			<section id="menuPanel" data-display="overlay" data-position-fixed="true" data-role="panel"  data-theme="b">
			<div class="ui-panel-inner" ><nav class="main-nav">
				<ul class="menupanel_one">
					<li>
					<a href="main" data-lid="home" class="ui-link active">MAIN</a>
					</li>
					
					<li>
					<a data-lid="vehicles" class="ui-link">업무보고</a>
					</li>
						<ul class="menupanel_two">
							<li>
								<a href="reportingregist" data-lid="mobile_apps" class="ui-link">등 록</a>
							</li>
							<li>
								<a href="todayreporting" data-lid="mobile_apps" class="ui-link">일일업무</a>
							</li>
							<li>
								<a href="weekreporting" data-lid="mobile_apps" class="ui-link">주간업무</a>
							</li>
							<li>
								<a href="monthreporting" data-lid="mobile_apps" class="ui-link">월간업무</a>
							</li>
						</ul>
					<li>
						
					<a data-lid="vehicles" class="ui-link">회의록</a>
					
					</li>
						<ul class="menupanel_two">
							<li>
								<a href="minutesregist" data-lid="mobile_apps" class="ui-link">등 록</a>
							</li>
							<li>
								<a href="minuteslist" data-lid="mobile_apps" class="ui-link">지난 회의록</a>
							</li>
						</ul>
				
					<li>
						<a data-lid="mobile_apps" class="ui-link">거래처 관리</a>
					</li>
						<ul class="menupanel_two">
							<li>
								<a href="accountlist" data-lid="mobile_apps" class="ui-link">거래처 보기</a>
							</li>
							<li>
								<a href="accountregist" data-lid="mobile_apps" class="ui-link">거래처 등록</a>
							</li>							
						</ul>
					
					<li>
						<a href="location" data-lid="mobile_apps" class="ui-link" >팀원 위치 보기</a>
						<input type='hidden' id='fepid' value='${sessionScope.userLoginInfo.epid}' />
					</li>
					
					<li>
						<a href="#companybbs" data-lid="owner_site" >사내 게시판</a>
					</li>
					<li>
						<a href="teambbslist" data-lid="mobile_apps" class="ui-link"  >팀 게시판</a>
					</li>	
					<li>
						<a data-lid="owner_site" >PT</a>
					</li>
						<ul class="menupanel_two">
							<li>
								<a href="ptregist" data-lid="mobile_apps" class="ui-link">등 록</a>
							</li>
							<li>
								<a href="ptview" data-lid="mobile_apps" class="ui-link">보 기</a>
							</li>							
						</ul>
					
				</ul>
				</nav></div>
			</section>	
			
			
			
					
			<div data-role="panel" id="rightpanel" data-display="overlay" data-position="right" data-theme="b">
				
			</div>
			
			
			
			<div data-role="content" class="ui-panel-content-wrap">
			 	
						<input type="button" id="searchall" value="전체조회"  />
						<input type="button" id="search1" value="1 조회"  />
						<input type="button" id="search2" value="2 조회"  />
						<input type="button" id="search3" value="3 조회"  />
						<input type="button" id="search4" value="4 조회"  />
						
						<div id="map" style="width:800px;height:500px;"></div>
						
						<!-- <input type='hidden' id='epid' value=${sessionScope.userLoginInfo.epid} /> -->
			</div>
	
	
	
</body>

<script>

////////////////////// 본인위치따기 ////////////////////////

 function initLocation()
   {
    var myGps = getLocation();
    if(myGps == null) return false;
    myLocation(myGps);
   }
   function getLocation()
   {
	   	console.log("get location !!");
    if(navigator.geolocation)
    {
    	console.log("Check complite !!");
     return navigator.geolocation;
    }
    	console.log("이 브라우져는 위치정보를 지원하지 않는 브라우져입니다.");
    return null;
   }

   
   var html = ""; //data 저장
   
 //내위치보내기
   function myLocation(myGps)
   {
    myGps.getCurrentPosition(function (position) {
      
      position.coords.timestamp; // 정보를 얻은 시간 (ms)
      position.coords.latitude; // 위도
      position.coords.longitude; // 경도
      position.coords.accuracy; // 위도, 경도 오차 (m)
      position.coords.altitude; // 고도
      position.coords.altitudeAccuracy; // 고도 오차 (m)
      position.coords.speed; // 진행속도 (m/s)
      position.coords.heading; // 정북의 시계방향 각도
      
		//	var a = "mm0001";
		$.post('location/setLocation' , {latitude : position.coords.latitude , longitude : position.coords.longitude}).done(function(data) {
  	//	$.post('local/setLocation' , {epid : a , latitude : position.coords.latitude , longitude : position.coords.longitude}).done(function(data) {	
		console.log(data);  
  		html = data;
			
	  });
		  
    });
   
   }
   
	var myid = $('#fepid').val();

	$('#search1').on('click',function(event){
		
		
		console.log( myid );
	
		////////타겟 아이디 세팅해야됨/////////
		
		
		
		
		
		var map;
		map = new daum.maps.Map(document.getElementById('map'), {
			center: new daum.maps.LatLng(html.myid.x, html.myid.y),
			level: 5
		});
		
		var marker = new daum.maps.Marker({
			position: new daum.maps.LatLng(html.a1.x, html.a1.y),
			title : "고진주"
		});
		marker.setMap(map);
	});
	
	$('#search2').on('click',function(event){
		
		
		
		if(html.mm0002 == null){
			alert("위치를 조회할수 없습니다");
		}
		  
		var map;
		map = new daum.maps.Map(document.getElementById('map'), {
			center: new daum.maps.LatLng(html.myid.x, html.myid.y)
		});
		
		var marker = new daum.maps.Marker({
			position: new daum.maps.LatLng(html.a2.x, html.a2.y)
		});
		marker.setMap(map);
	});
	

	$('#search3').on('click',function(event){
		
		
		if(html.mm0003 == null){
			alert("위치를 조회할수 없습니다");
		}
		
		var map;
		map = new daum.maps.Map(document.getElementById('map'), {
			center: new daum.maps.LatLng(html.myid.x, html.myid.y)
		});
		
		var marker = new daum.maps.Marker({
			position: new daum.maps.LatLng(html.mm0003.x, html.mm0003.y)
		});
		marker.setMap(map);
	});
	

	$('#search4').on('click',function(event){
		
	
		if(html.mm0004 == null){
			alert("위치를 조회할수 없습니다");
			
		}
		
		var map;
		map = new daum.maps.Map(document.getElementById('map'), {
			center: new daum.maps.LatLng(html.myid.x, html.myid.y)
		});
		
		var marker = new daum.maps.Marker({
			position: new daum.maps.LatLng(html.mm0004.x, html.mm0004.y)
		});
		marker.setMap(map);
	});
	
	$('#searchall').on('click',function(event){
		
		console.log(html.mm0001.x, html.mm0001.y);
		
		var map;
		map = new daum.maps.Map(document.getElementById('map'), {
			center: new daum.maps.LatLng(html.myid.x, html.myid.y),
			level:10
		});
		
		var marker = new daum.maps.Marker({
			position: new daum.maps.LatLng(37.566535, 126.977969),
			title:"mm001"
		});
		marker.setMap(map);
		
		var marker1 = new daum.maps.Marker({
			position: new daum.maps.LatLng(37.666535, 126.975969),
			title:"mm0002"
		});
		marker1.setMap(map);
		
		var marker2 = new daum.maps.Marker({
			position: new daum.maps.LatLng(37.666535, 126.865969),
			title:"mm0003"
		});
		marker2.setMap(map);
		
		var marker3 = new daum.maps.Marker({
			position: new daum.maps.LatLng(37.566535, 126.925969),
			title:"mm0004"
		});
		marker3.setMap(map);
	});
	
	/* 우선 지도 안나오게
	function init() {
		map = new daum.maps.Map(document.getElementById('map'), {
			center: new daum.maps.LatLng(37.440843801930384,127.14749505729776),
			level: 5
		});
	} */
	
	window.onload = initLocation;
//	init();
	
</script>


</html>